home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C++
/
Frameworks
/
Sprocket Framework DR2
/
Sprocket Framework
/
UResources.cp
< prev
next >
Wrap
Text File
|
1996-06-15
|
10KB
|
586 lines
/*
File: UResources.cp
Project: Sprocket Framework 1.1 (DR2), released 6/15/96
Contains: Resource compatibilty routines which do the right thing for System 7 or 8
If compiling for MacOS 8 only, calls are mapped directly without any glue
To Do: ?
Sprocket Major Contributors:
----------------------------
Dave Falkenburg, producer of Sprocket 1.0
Bill Hayden, producer of Sprocket 1.1
Steve Sisak, producer of the upcoming Sprocket 2.0
Pete Alexander Steve Falkenburg Randy Thelen
Eric Berdahl Nitin Ganatra Chris K. Thomas
Marshall Clow Dave Hershey Leonard Rosenthal
Tim Craycroft Dave Mark Dean Yu
David denBoer Gary Powell
Cameron Esfahani Jon Summers Apple Computer, Inc.
Comments, Additions, or Corrections:
------------------------------------
Bill Hayden, Nikol Software <nikol@codewell.com>
*/
// If we are compiling only for MacOS 8 or later only, we don’t need any of this.
// This is for savvy binary compatibility between System 7 and MacOS 8 only.
#if (!BUILDING_FOR_SYSTEM8)
#include "Sprocket.h"
#include "UResources.h"
// This may come in handy at some later time.
#define System8ResourceManagerUnavailable ( GENERATING68K || (gSystemVersion < 0x0800) )
OSStatus RMCloseResFileCompat(ResFileRefNum refNum)
{
if (System8ResourceManagerUnavailable)
{
CloseResFile(refNum);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMCloseResFile(refNum);
#endif
}
OSStatus RMUpdateResFileCompat(ResFileRefNum refNum)
{
if (System8ResourceManagerUnavailable)
{
UpdateResFile(refNum);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMUpdateResFile(refNum);
#endif
}
OSStatus RMUseResFileCompat(ResFileRefNum refNum)
{
if (System8ResourceManagerUnavailable)
{
UseResFile(refNum);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMUseResFile(refNum);
#endif
}
OSStatus RMCurResFileCompat(ResFileRefNum* refNum)
{
if (System8ResourceManagerUnavailable)
{
*refNum = CurResFile();
return ResError();
}
#if GENERATINGPOWERPC
else
return RMCurResFile(refNum);
#endif
}
OSStatus RMHomeResFileCompat(Handle theResource, ResFileRefNum *refNum)
{
if (System8ResourceManagerUnavailable)
{
*refNum = HomeResFile(theResource);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMHomeResFile(theResource, refNum);
#endif
}
OSStatus RMAddResourceCompat(Handle theData, ResType theType, ResID theID, ConstStr255Param name)
{
if (System8ResourceManagerUnavailable)
{
AddResource(theData, theType, theID, name);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMAddResource(theData, theType, theID, name);
#endif
}
OSStatus RMRemoveResourceCompat(Handle theResource)
{
if (System8ResourceManagerUnavailable)
{
RemoveResource(theResource);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMRemoveResource(theResource);
#endif
}
OSStatus RMCountTypesCompat(Boolean oneDeep, UInt32 *count)
{
if (System8ResourceManagerUnavailable)
{
if(oneDeep)
*count = Count1Types();
else
*count = CountTypes();
return ResError();
}
#if GENERATINGPOWERPC
else
return RMCountTypes(oneDeep, count);
#endif
}
OSStatus RMGetIndexedTypeCompat(UInt32 index, Boolean oneDeep, ResType *theType)
{
if (System8ResourceManagerUnavailable)
{
if(oneDeep)
Get1IndType(theType, index);
else
GetIndType(theType, index);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMGetIndexedType(index, oneDeep, theType);
#endif
}
OSStatus RMCountResourcesCompat(ResType theType, Boolean oneDeep, UInt32 *count)
{
if (System8ResourceManagerUnavailable)
{
if(oneDeep)
*count = Count1Resources(theType);
else
*count = CountResources(theType);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMCountResources(theType, oneDeep, count);
#endif
}
OSStatus RMGetIndexedResourceCompat(ResType theType, UInt32 index, Boolean oneDeep, Boolean resLoad, Handle *handle)
{
if (System8ResourceManagerUnavailable)
{
OSStatus err = 0L;
UInt8 saveResLoad;
saveResLoad = LMGetResLoad();
SetResLoad(resLoad);
if(oneDeep)
*handle = Get1IndResource(theType, index);
else
*handle = GetIndResource(theType, index);
err = ResError();
SetResLoad(saveResLoad);
return err;
}
#if GENERATINGPOWERPC
else
return RMGetIndexedResource(theType, index, oneDeep, resLoad, handle);
#endif
}
OSStatus RMGetResourceCompat(ResType theType, ResID theID, Boolean oneDeep, Boolean resLoad, Handle *handle)
{
if (System8ResourceManagerUnavailable)
{
OSStatus err;
UInt8 saveResLoad;
saveResLoad = LMGetResLoad();
SetResLoad(resLoad);
if(oneDeep)
*handle = Get1Resource(theType, theID);
else
*handle = GetResource(theType, theID);
err = ResError();
SetResLoad(saveResLoad);
return err;
}
#if GENERATINGPOWERPC
else
return RMGetResource(theType, theID, oneDeep, resLoad, handle);
#endif
}
OSStatus RMGetNamedResourceCompat(ResType theType, ConstStr255Param name, Boolean oneDeep, Boolean resLoad, Handle *handle)
{
if (System8ResourceManagerUnavailable)
{
OSStatus err;
UInt8 saveResLoad;
saveResLoad = LMGetResLoad();
SetResLoad(resLoad);
if(oneDeep)
*handle = Get1NamedResource(theType, name);
else
*handle = GetNamedResource(theType, name);
err = ResError();
SetResLoad(saveResLoad);
return err;
}
#if GENERATINGPOWERPC
else
return RMGetNamedResource(theType, name, oneDeep, resLoad, handle);
#endif
}
OSStatus RMLoadResourceCompat(Handle theResource)
{
if (System8ResourceManagerUnavailable)
{
LoadResource(theResource);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMLoadResource(theResource);
#endif
}
OSStatus RMReleaseResourceCompat(Handle theResource)
{
if (System8ResourceManagerUnavailable)
{
ReleaseResource(theResource);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMReleaseResource(theResource);
#endif
}
OSStatus RMDetachResourceCompat(Handle theResource)
{
if (System8ResourceManagerUnavailable)
{
DetachResource(theResource);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMDetachResource(theResource);
#endif
}
OSStatus RMChangedResourceCompat(Handle theResource)
{
if (System8ResourceManagerUnavailable)
{
ChangedResource(theResource);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMChangedResource(theResource);
#endif
}
OSStatus RMWriteResourceCompat(Handle theResource)
{
if (System8ResourceManagerUnavailable)
{
WriteResource(theResource);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMWriteResource(theResource);
#endif
}
OSStatus RMSetResourceSizeCompat(Handle theResource, SInt32 newSize)
{
if (System8ResourceManagerUnavailable)
{
SetResourceSize(theResource, newSize);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMSetResourceSize(theResource, newSize);
#endif
}
OSStatus RMUniqueIDCompat(ResType theType, Boolean oneDeep, ResID *idPtr)
{
if (System8ResourceManagerUnavailable)
{
if(oneDeep)
*idPtr = Unique1ID(theType);
else
*idPtr = UniqueID(theType);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMUniqueID(theType, oneDeep, idPtr);
#endif
}
OSStatus RMGetResAttributesCompat(Handle theResource, ResAttributes *attributes)
{
if (System8ResourceManagerUnavailable)
{
*attributes = GetResAttrs(theResource);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMGetResAttributes(theResource, attributes);
#endif
}
OSStatus RMGetResInfoCompat(Handle theResource, ResType *typePtr, ResID *idPtr, Str255 name)
{
if (System8ResourceManagerUnavailable)
{
GetResInfo(theResource, idPtr, typePtr, name);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMGetResInfo(theResource, typePtr, idPtr, name);
#endif
}
OSStatus RMSetResInfoCompat(Handle theResource, ResType typePtr, ResID theID, ConstStr255Param name)
{
if (System8ResourceManagerUnavailable)
{
SetResInfo(theResource, theID, name);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMSetResInfo(theResource, typePtr, theID, name);
#else
#pragma unused(typePtr)
#endif
}
OSStatus RMSetResAttributesCompat(Handle theResource, ResAttributes attrs)
{
if (System8ResourceManagerUnavailable)
{
SetResAttrs(theResource, attrs);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMSetResAttributes(theResource, attrs);
#endif
}
OSStatus RMReadPartialResourceCompat(Handle theResource, UInt32 offset, void *buffer, UInt32 count)
{
if (System8ResourceManagerUnavailable)
{
ReadPartialResource(theResource, offset, buffer, count);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMReadPartialResource(theResource, offset, buffer, count);
#endif
}
OSStatus RMWritePartialResourceCompat(Handle theResource, UInt32 offset, const void *buffer, UInt32 count)
{
if (System8ResourceManagerUnavailable)
{
OSStatus outErr = 0L;
WritePartialResource(theResource, offset, buffer, count);
outErr = ResError();
return outErr;
}
#if GENERATINGPOWERPC
else
return RMWritePartialResource(theResource, offset, buffer, count);
#endif
}
OSStatus RMGetResourceSizeCompat(Handle theResource, SInt32 *size)
{
if (System8ResourceManagerUnavailable)
{
*size = GetResourceSizeOnDisk(theResource);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMGetResourceSize(theResource, size);
#endif
}
OSStatus RMSetResErrProcCompat(ResErrUPP proc)
{
if (System8ResourceManagerUnavailable)
{
LMSetResErrProc(proc);
return noErr;
}
#if GENERATINGPOWERPC
else
return RMSetResErrProc(proc);
#endif
}
OSStatus RMSetResFileReadOnlyStateCompat(ResFileRefNum refNum, Boolean isReadOnly)
{
if (System8ResourceManagerUnavailable)
{
SetResFileAttrs(refNum, isReadOnly ? mapReadOnly : 0);
return ResError();
}
#if GENERATINGPOWERPC
else
return RMSetResFileReadOnlyState(refNum, isReadOnly);
#endif
}
OSStatus RMGetResFileReadOnlyStateCompat(ResFileRefNum refNum, Boolean *isReadOnly)
{
if (System8ResourceManagerUnavailable)
{
short attrs;
attrs = GetResFileAttrs(refNum);
if(attrs & mapReadOnly)
*isReadOnly = true;
else
*isReadOnly = false;
return ResError();
}
#if GENERATINGPOWERPC
else
return RMGetResFileReadOnlyState(refNum, isReadOnly);
#endif
}
#endif